//webpack配置文件

var path=require('path')

//在内存中根据指定页面生成一份首页，同时将打包好的的.js注入到页面底部
var htmlWebpackPlugin=require('html-webpack-plugin')
//这里需要注意的是，15.x之后版本的vue-loader还需要配置插件：
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports={
    entry:path.join(__dirname,'./src/index.js'),//入口
    output:{//出口
        path:path.join(__dirname,'./dist'),
        filename:'bundle.js'
    },
    plugins:[//所有webpack插件的配置节点
        new htmlWebpackPlugin({
            template:path.join(__dirname,'./src/index.html'),
            filename:'index.html'
        }),
        //再在plugins属性中增加一条：
        new VueLoaderPlugin()
    ],
    module:{
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
            // {test:/\.(jpg|gif|png)$/,use:'url-loader'},
            {
                test: /\.(png|jpe?g|gif)$/i,
                options: {
                    name: '[path][name].[ext]',
                    esModule: false
                },
                loader: 'file-loader' // https://www.npmjs.com/package/file-loader
            },
            {test:/\.(ttf|woff2|eot|svg|woff)$/,use:'url-loader'},
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
            {test:/\.vue$/,use:'vue-loader'},
            {test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader']}

        ]
    },
    resolve:{
        alias:{
            // "vue$":'vue/dist/vue.js'
        }
    }
}